
jQuery(document).ready(function($) {
    'use strict';

    // Initialize the jQuery File Upload widget:
    $('#fileupload').fileupload({
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        url: 'multi_uploader'

    });

    var  acceptFileTypes = '@acceptFileTypes';
    $('#fileupload').fileupload('option', {
        dataType : 'json',
        autoUpload : false,
        minFileSize : undefined,
        acceptFileTypes: /(\.|\/)(doc|gif|jpe?g|png|pdf)$/i,
        sequentialUploads: true,
        singleFileUploads: true,
        add : function(e, data) {
            $('#progress .bar2').show();
            if ($.browser.msie && parseInt($.browser.version, 10) < 10) {
                $('#progress .bar2').css({
                    "background" : "url(images/progressbar.gif) no-repeat",
                    "width" : "100%"
                })
            } else {
                $('#progress .bar2').css({
                    'background-color' : "green",
                    'width' : '0%'
                });
            }
            $("#progress").text("上传中...")
            data.submit();
        },

        change : function(e, data) {
            $.each(data.files, function(index, file) {
                $('#progress .bar2').show();
                if ($.browser.msie && parseInt($.browser.version, 10) < 10) {
                    $('#progress .bar').css({
                        "background" : "url(images/progressbar.gif) no-repeat",
                        "width" : "100%"
                    })
                } else {
                    $('#progress .bar').css({
                        'background-color' : "green",
                        'width' : '10%'
                    });
                }
            });
        },
        done : function(e, data) {
            $.each(data.result, function(index, file) {

                var vOutput = "";
                vOutput += "&nbsp;<b>" + '上传成功'+ "</b>";
                $("#progress").text(file.name)
                $("#progress").append(vOutput);
            });
        },
        progressall : function(e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10);
            $('#progress .value').css({'background-color' : "green",'width': progress + '%'});
        },
        fail:function(e,data) {



        }


    });

});
